﻿<!DOCTYPE html>
<html>
<head>
    <title>ChatRoom</title>
    <script src="Scripts/jquery-1.6.4.min.js"></script>
    <script src="Scripts/jquery.signalR-2.1.2.min.js"></script>
    <script src="http://localhost:8080/signalr/hubs"></script>
    
    <script type="text/javascript">
        $(function () {
            $.connection.hub.url = "http://localhost:8080/signalr";

            var chat = $.connection.myHub;
            chat.client.addMessage = function (name, message) {
                $('#AddText').append('<strong>' + name + '</strong>: ' + message + '<br/>');
            };
            
            $('#teksnama').val(prompt('Masukan nama:', ''));
            $('#PesanChat').focus();
            
            $.connection.hub.start().done(function () {
                $('#kirimpesan').click(function () {
                    chat.server.send($('#teksnama').val(), $('#PesanChat').val());
                    $('#PesanChat').val('').focus();
                });
            });
        });
    </script>
</head>
<body>
    <div class="container">
        <input type="text" id="PesanChat" />
        <input type="button" id="kirimpesan" value="Kirim" />
        <input type="hidden" id="teksnama" />
        <div id="AddText"></div>
    </div>
</body>
</html>